<template>
  <div class="buttonAdd">
    <el-button type="primary" size="mini"  @click="dialogFormVisibleAdd = true">退回重报</el-button>
    <el-dialog :close-on-click-modal="false"  title="退回重报" :visible.sync="dialogFormVisibleAdd" @opened="$store.commit('dialogTop')" @close="resetForm('ruleFormAdd')">
      <el-form :model="ruleFormAdd" :rules="rulesAdd" ref="ruleFormAdd" label-width="80px" class="demo-ruleForm">
        <el-form-item label="退回原因" :maxlength="100" prop="backAgree" :rules="{required: true, message: '退回原因不能为空', }">
          <el-input type="textarea"  size="small"  :autosize="{ minRows: 3, maxRows: 6}" v-model="ruleFormAdd.backAgree" auto-complete="off" placeholder="退回原因"></el-input>
        </el-form-item>
        <el-form-item></el-form-item>
      </el-form>
      <div style="text-align: center;margin: 17px 0 16px 0;">
        <el-button  size="small" @click="dialogFormVisibleAdd = false">取 消</el-button>
        <el-button style="margin-left: 20px;" type="primary" size="small" @click="submitForm('ruleFormAdd')">确 定</el-button>
      </div>

    </el-dialog>
  </div>
</template>

<script>

  export default {
    props:["taskId","agencyId"],
    data () {
      return {
        ruleFormAdd: {
          "backAgree": "",
        },
        dialogFormVisibleAdd: false,
        rulesAdd: {}
      }
    },
    created(){

    },
    methods: {

      //提交回调
      handleDiaSureAdd(){
        this.axios.post(process.env.API_HOST + '/examine/updateAgencyDetail', {...this.ruleFormAdd,taskId:this.taskId,agencyId:this.agencyId})
          .then(response => {
            let result=response.data
            if (result.code == 200) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              });
              this.dialogFormVisibleAdd = false
              this.$emit('handleClose')
              this.resetForm('ruleFormAdd')
            }

          })
          .catch(error => {
            console.log(error);
          });
      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.handleDiaSureAdd()
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus" >
  .buttonAdd
    display inline-block

</style>
